package bear.download;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class MyContentHandler extends DefaultHandler {
	static String title;
	static String description;
	public static boolean cuole=false;
	String tagName;
	//public static boolean key;
	public void startDocument() throws SAXException {
		//System.out.println("````````begin````````");
	}

	public void endDocument() throws SAXException {
		//System.out.println("````````end````````");
	}

	public void startElement(String namespaceURI, String localName,
			String qName, Attributes attr) throws SAXException {
		tagName = localName;
		if (localName.equals("")) {
			//获取标签的全部属性
			for (int i = 0; i < attr.getLength(); i++) {
				System.out.println(attr.getLocalName(i) + "=" + attr.getValue(i));
		}
		}
	}

	public void endElement(String namespaceURI, String localName, String qName)
			throws SAXException {
		//在worker标签解析完之后，会打印出所有得到的数据
		tagName = "";
		if (localName.equals("channel")) {
			printout();
		}
	}
	public void characters(char[] ch, int start, int length)
			throws SAXException {
		if (tagName.equals("title"))
			title = new String(ch, start, length);
		else if (tagName.equals("description"))
			description = new String(ch, start, length);
	}

	public void printout() {
		if(title.equals("错误消息 ")||description.equals("密码或用户名错误！")) {
			cuole=false;
		}else {
			cuole=true;
		}
	}
}